<template>
    <div class="header">
        <div class="title">黑山羊-智慧养殖系统</div>
        <div class="active">
            <div class="u">
                <img style="width: 24px;" src="@/assets/icon.png" alt="">
                 &nbsp;&nbsp;{{ userInfo.account }}</div>
            <span class="quitBtn" @click="outlogin">退出</span>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            userInfo: {}

        }
    },
    methods: {
        outlogin() {
            // 清空本地存储的数据
            localStorage.clear()
            // 跳转到登录页
            this.$router.push('/login')
        }
    },

    created() {
        this.userInfo = JSON.parse(localStorage.getItem('user'));
    }

}
</script>

<style lang="scss" scoped>
.header {
    width: 100%;
    height: 50px;
    background-color: #409EFF;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    width: 200px;
    height: 100%;
    display: flex;
    align-items: center;
    font-size: 20px;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0 0 0 15px;
}
.active{
    width: 120px;
    display: flex;
    margin: 0 20px;
    padding: 20px;
    justify-content: space-between;
}
.quitBtn{
    color: #ffffff;
    cursor: pointer;
}
.quitBtn:hover{
    color: #e65656;
    text-decoration: underline;
}
.u{
    display: flex;
    align-items: center;
    color: #FFFFFF;
}
</style>